package hk.m4s.lr.repair.test.service.user;

import android.content.Context;
import java.util.Map;

import framework.common.widgets.dialogs.UeDialog;
import framework.common.zanetwork.AcountUeHttpUrl;
import framework.common.zanetwork.UeHttpUrl;
import framework.common.zanetwork.core.HttpCallback;
import framework.common.zanetwork.core.ResponseCallback;
import hk.m4s.lr.repair.test.model.CommonToolModelResult;
import hk.m4s.lr.repair.test.model.MyOrderModel;
import hk.m4s.lr.repair.test.model.MyOrderTuiModel;
import hk.m4s.lr.repair.test.model.MyToolModelResult;
import hk.m4s.lr.repair.test.model.UserinfoModel;
import hk.m4s.lr.repair.test.service.BaseService;
import okhttp3.Response;

/**
 * Created by qi.wang on 2017/4/1.
 */

public class MyService extends BaseService{
    public static void userInfo (final Context context, Map<String, Object> parmas, final ResponseCallback<UserinfoModel> callback) {

        httpHelper.post(UeHttpUrl.userById(), parmas, new HttpCallback<UserinfoModel>() {
            @Override
            public void onRequestBefore() {

            }
            @Override
            public void onSuccess(Response response, UserinfoModel o) {

                callback.onSuccess(o);
            }

            @Override
            public void onError(Response response, int errorCode, Exception e) {

                callback.onError(response, errorCode, null, e);

            }

            @Override
            public void onFailure(Response response, String failureMsg, int code) {

                callback.onError(response, code, failureMsg, null);
            }
        });
    }
    public static void userByIdUpdate (final Context context, Map<String, Object> parmas, final ResponseCallback<UserinfoModel> callback) {

        httpHelper.post(UeHttpUrl.userByIdUpdate(), parmas, new HttpCallback<UserinfoModel>() {
            @Override
            public void onRequestBefore() {

            }

            @Override
            public void onSuccess(Response response, UserinfoModel o) {
                callback.onSuccess(o);
            }

            @Override
            public void onError(Response response, int errorCode, Exception e) {

                callback.onError(response, errorCode, null, e);

            }

            @Override
            public void onFailure(Response response, String failureMsg, int code) {

                callback.onError(response, code, failureMsg, null);
            }
        });
    }
    public static void updatePhone (final Context context, Map<String, Object> parmas, final ResponseCallback<UserinfoModel> callback) {

        httpHelper.post(UeHttpUrl.putTel(), parmas, new HttpCallback<UserinfoModel>() {
            @Override
            public void onRequestBefore() {

            }

            @Override
            public void onSuccess(Response response, UserinfoModel o) {

                callback.onSuccess(o);
            }

            @Override
            public void onError(Response response, int errorCode, Exception e) {

                callback.onError(response, errorCode, null, e);

            }

            @Override
            public void onFailure(Response response, String failureMsg, int code) {

                callback.onError(response, code, failureMsg, null);
            }
        });
    }
    public static void checkPass (final Context context, Map<String, Object> parmas, final ResponseCallback<UserinfoModel> callback) {

        httpHelper.post(AcountUeHttpUrl.checkPass(), parmas, new HttpCallback<UserinfoModel>() {
            @Override
            public void onRequestBefore() {
                UeDialog.showprogressDialog(context,"","验证中...",false);
            }

            @Override
            public void onSuccess(Response response, UserinfoModel o) {
                UeDialog.hideProgress();
                callback.onSuccess(o);
            }

            @Override
            public void onError(Response response, int errorCode, Exception e) {
                UeDialog.hideProgress();
                callback.onError(response, errorCode, null, e);

            }

            @Override
            public void onFailure(Response response, String failureMsg, int code) {
                UeDialog.hideProgress();
                callback.onError(response, code, failureMsg, null);
            }
        });
    }
    public static void deviceUpdateImg (final Context context, Map<String, Object> parmas, final ResponseCallback<Map> callback) {

        httpHelper.post(UeHttpUrl.deviceUpdateImg(), parmas, new HttpCallback<Map>() {
            @Override
            public void onRequestBefore() {

            }

            @Override
            public void onSuccess(Response response, Map o) {

                callback.onSuccess(o);
            }

            @Override
            public void onError(Response response, int errorCode, Exception e) {

                callback.onError(response, errorCode, null, e);

            }

            @Override
            public void onFailure(Response response, String failureMsg, int code) {

                callback.onError(response, code, failureMsg, null);
            }
        });
    }
    public static void commonToolList (final Context context, Map<String, Object> parmas, final ResponseCallback<CommonToolModelResult> callback) {

        httpHelper.post(UeHttpUrl.commonToolList(), parmas, new HttpCallback<CommonToolModelResult>() {
            @Override
            public void onRequestBefore() {

            }

            @Override
            public void onSuccess(Response response, CommonToolModelResult o) {

                callback.onSuccess(o);
            }

            @Override
            public void onError(Response response, int errorCode, Exception e) {

                callback.onError(response, errorCode, null, e);

            }

            @Override
            public void onFailure(Response response, String failureMsg, int code) {

                callback.onError(response, code, failureMsg, null);
            }
        });
    }
    public static void toolUseList (final Context context, Map<String, Object> parmas, final ResponseCallback<CommonToolModelResult> callback) {

        httpHelper.post(UeHttpUrl.toolUseList(), parmas, new HttpCallback<CommonToolModelResult>() {
            @Override
            public void onRequestBefore() {

            }

            @Override
            public void onSuccess(Response response, CommonToolModelResult o) {

                callback.onSuccess(o);
            }

            @Override
            public void onError(Response response, int errorCode, Exception e) {

                callback.onError(response, errorCode, null, e);

            }

            @Override
            public void onFailure(Response response, String failureMsg, int code) {

                callback.onError(response, code, failureMsg, null);
            }
        });
    }
    public static void toolBoxList (final Context context, Map<String, Object> parmas, final ResponseCallback<MyToolModelResult> callback) {

        httpHelper.post(UeHttpUrl.toolBoxList(), parmas, new HttpCallback<MyToolModelResult>() {
            @Override
            public void onRequestBefore() {

            }

            @Override
            public void onSuccess(Response response, MyToolModelResult o) {

                callback.onSuccess(o);
            }

            @Override
            public void onError(Response response, int errorCode, Exception e) {

                callback.onError(response, errorCode, null, e);

            }

            @Override
            public void onFailure(Response response, String failureMsg, int code) {

                callback.onError(response, code, failureMsg, null);
            }
        });
    }
    public static void findUserReturnOrder (final Context context, Map<String, Object> parmas, final ResponseCallback<MyOrderTuiModel> callback) {

        httpHelper.post("http://47.92.142.157:8081/cym_back/app/store/carownerSalesReturnOrder/findUserReturnOrder", parmas, new HttpCallback<MyOrderTuiModel>() {
            @Override
            public void onRequestBefore() {
                UeDialog.showprogressDialog(context,"","加载中...",false);
            }
            @Override
            public void onSuccess(Response response, MyOrderTuiModel o) {
                UeDialog.hideProgress();
                callback.onSuccess(o);
            }

            @Override
            public void onError(Response response, int errorCode, Exception e) {
                UeDialog.hideProgress();
                callback.onError(response, errorCode, null, e);

            }

            @Override
            public void onFailure(Response response, String failureMsg, int code) {
                UeDialog.hideProgress();
                callback.onError(response, code, failureMsg, null);
            }
        });
    }
    public static void findOrderListByUser (final Context context, Map<String, Object> parmas, final ResponseCallback<MyOrderModel> callback) {

        httpHelper.post(" http://47.92.142.157:8081/cym_back/app/store/carownerOrder/findOrderListByUser", parmas, new HttpCallback<MyOrderModel>() {
            @Override
            public void onRequestBefore() {
                UeDialog.showprogressDialog(context,"","加载中...",false);
            }
            @Override
            public void onSuccess(Response response, MyOrderModel o) {
                UeDialog.hideProgress();
                callback.onSuccess(o);
            }

            @Override
            public void onError(Response response, int errorCode, Exception e) {
                UeDialog.hideProgress();
                callback.onError(response, errorCode, null, e);

            }

            @Override
            public void onFailure(Response response, String failureMsg, int code) {
                UeDialog.hideProgress();
                callback.onError(response, code, failureMsg, null);
            }
        });
    }
}
